﻿#region Copyright

// /*
// SilverlightInEnterprise
// SilverlightInEnterprise.Caching
// Reference.cs
// 
// Author: Matt Van Horn
// Created 11/16/2011 12:44 PM
// Copyright: Silverlight in the Enterprise www.slinenterprise.com
// 
// Licensed under MS-PL http://www.opensource.org/licenses/MS-PL and while you 
// may use this in anyway you see fit and owe us nothing to do so, we wouldn't mind knowing that you got value out of the work we did (so we will do more) so 
// we ask that you leave a comment on www.slinenterprise.com or on the codeplex site slinenterprise.codeplex.com
// 
// */

#endregion

namespace SilverlightInEnterprise.Caching.SalesService
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.slinenterprise.com/Caching",
        ConfigurationName = "SalesService.ISalesService")]
    public interface ISalesService
    {
        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true,
            Action = "http://www.slinenterprise.com/Caching/ISalesService/GetSalesOrderItems",
            ReplyAction = "http://www.slinenterprise.com/Caching/ISalesService/GetSalesOrderItemsResponse")]
        System.IAsyncResult BeginGetSalesOrderItems(int salesId, System.AsyncCallback callback, object asyncState);

        System.Collections.ObjectModel.ObservableCollection
            <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem> EndGetSalesOrderItems(
            System.IAsyncResult result);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface ISalesServiceChannel : SilverlightInEnterprise.Caching.SalesService.ISalesService,
                                            System.ServiceModel.IClientChannel
    {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class GetSalesOrderItemsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {
        private object[] results;

        public GetSalesOrderItemsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled,
                                                    object userState) :
                                                        base(exception, cancelled, userState)
        {
            this.results = results;
        }

        public
            System.Collections.ObjectModel.ObservableCollection
                <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem> Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return
                    ((
                     System.Collections.ObjectModel.ObservableCollection
                         <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem>) (this.results[0]));
            }
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class SalesServiceClient :
        System.ServiceModel.ClientBase<SilverlightInEnterprise.Caching.SalesService.ISalesService>,
        SilverlightInEnterprise.Caching.SalesService.ISalesService
    {
        private BeginOperationDelegate onBeginGetSalesOrderItemsDelegate;

        private EndOperationDelegate onEndGetSalesOrderItemsDelegate;

        private System.Threading.SendOrPostCallback onGetSalesOrderItemsCompletedDelegate;

        private BeginOperationDelegate onBeginOpenDelegate;

        private EndOperationDelegate onEndOpenDelegate;

        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;

        private BeginOperationDelegate onBeginCloseDelegate;

        private EndOperationDelegate onEndCloseDelegate;

        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;

        public SalesServiceClient()
        {
        }

        public SalesServiceClient(string endpointConfigurationName) :
            base(endpointConfigurationName)
        {
        }

        public SalesServiceClient(string endpointConfigurationName, string remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public SalesServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public SalesServiceClient(System.ServiceModel.Channels.Binding binding,
                                  System.ServiceModel.EndpointAddress remoteAddress) :
                                      base(binding, remoteAddress)
        {
        }

        public System.Net.CookieContainer CookieContainer
        {
            get
            {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager =
                    this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null))
                {
                    return httpCookieContainerManager.CookieContainer;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager =
                    this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null))
                {
                    httpCookieContainerManager.CookieContainer = value;
                }
                else
                {
                    throw new System.InvalidOperationException(
                        "Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
                        "ookieContainerBindingElement.");
                }
            }
        }

        public event System.EventHandler<GetSalesOrderItemsCompletedEventArgs> GetSalesOrderItemsCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult SilverlightInEnterprise.Caching.SalesService.ISalesService.BeginGetSalesOrderItems(
            int salesId, System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetSalesOrderItems(salesId, callback, asyncState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.Collections.ObjectModel.ObservableCollection
            <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem>
        SilverlightInEnterprise.Caching.SalesService.ISalesService.EndGetSalesOrderItems(System.IAsyncResult result)
        {
            return base.Channel.EndGetSalesOrderItems(result);
        }

        private System.IAsyncResult OnBeginGetSalesOrderItems(object[] inValues, System.AsyncCallback callback,
                                                              object asyncState)
        {
            int salesId = ((int) (inValues[0]));
            return ((SilverlightInEnterprise.Caching.SalesService.ISalesService) (this)).BeginGetSalesOrderItems(
                salesId, callback, asyncState);
        }

        private object[] OnEndGetSalesOrderItems(System.IAsyncResult result)
        {
            System.Collections.ObjectModel.ObservableCollection
                <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem> retVal =
                    ((SilverlightInEnterprise.Caching.SalesService.ISalesService) (this)).EndGetSalesOrderItems(result);
            return new object[]
                       {
                           retVal
                       };
        }

        private void OnGetSalesOrderItemsCompleted(object state)
        {
            if ((this.GetSalesOrderItemsCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.GetSalesOrderItemsCompleted(this,
                                                 new GetSalesOrderItemsCompletedEventArgs(e.Results, e.Error,
                                                                                          e.Cancelled, e.UserState));
            }
        }

        public void GetSalesOrderItemsAsync(int salesId)
        {
            this.GetSalesOrderItemsAsync(salesId, null);
        }

        public void GetSalesOrderItemsAsync(int salesId, object userState)
        {
            if ((this.onBeginGetSalesOrderItemsDelegate == null))
            {
                this.onBeginGetSalesOrderItemsDelegate = new BeginOperationDelegate(this.OnBeginGetSalesOrderItems);
            }
            if ((this.onEndGetSalesOrderItemsDelegate == null))
            {
                this.onEndGetSalesOrderItemsDelegate = new EndOperationDelegate(this.OnEndGetSalesOrderItems);
            }
            if ((this.onGetSalesOrderItemsCompletedDelegate == null))
            {
                this.onGetSalesOrderItemsCompletedDelegate =
                    new System.Threading.SendOrPostCallback(this.OnGetSalesOrderItemsCompleted);
            }
            base.InvokeAsync(this.onBeginGetSalesOrderItemsDelegate, new object[]
                                                                         {
                                                                             salesId
                                                                         }, this.onEndGetSalesOrderItemsDelegate,
                             this.onGetSalesOrderItemsCompletedDelegate, userState);
        }

        private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject) (this)).BeginOpen(callback, asyncState);
        }

        private object[] OnEndOpen(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject) (this)).EndOpen(result);
            return null;
        }

        private void OnOpenCompleted(object state)
        {
            if ((this.OpenCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.OpenCompleted(this,
                                   new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void OpenAsync()
        {
            this.OpenAsync(null);
        }

        public void OpenAsync(object userState)
        {
            if ((this.onBeginOpenDelegate == null))
            {
                this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
            }
            if ((this.onEndOpenDelegate == null))
            {
                this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
            }
            if ((this.onOpenCompletedDelegate == null))
            {
                this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
            }
            base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate,
                             userState);
        }

        private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject) (this)).BeginClose(callback, asyncState);
        }

        private object[] OnEndClose(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject) (this)).EndClose(result);
            return null;
        }

        private void OnCloseCompleted(object state)
        {
            if ((this.CloseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.CloseCompleted(this,
                                    new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void CloseAsync()
        {
            this.CloseAsync(null);
        }

        public void CloseAsync(object userState)
        {
            if ((this.onBeginCloseDelegate == null))
            {
                this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
            }
            if ((this.onEndCloseDelegate == null))
            {
                this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
            }
            if ((this.onCloseCompletedDelegate == null))
            {
                this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
            }
            base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate,
                             userState);
        }

        protected override SilverlightInEnterprise.Caching.SalesService.ISalesService CreateChannel()
        {
            return new SalesServiceClientChannel(this);
        }

        private class SalesServiceClientChannel :
            ChannelBase<SilverlightInEnterprise.Caching.SalesService.ISalesService>,
            SilverlightInEnterprise.Caching.SalesService.ISalesService
        {
            public SalesServiceClientChannel(
                System.ServiceModel.ClientBase<SilverlightInEnterprise.Caching.SalesService.ISalesService> client) :
                    base(client)
            {
            }

            public System.IAsyncResult BeginGetSalesOrderItems(int salesId, System.AsyncCallback callback,
                                                               object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = salesId;
                System.IAsyncResult _result = base.BeginInvoke("GetSalesOrderItems", _args, callback, asyncState);
                return _result;
            }

            public
                System.Collections.ObjectModel.ObservableCollection
                    <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem> EndGetSalesOrderItems(
                System.IAsyncResult result)
            {
                object[] _args = new object[0];
                System.Collections.ObjectModel.ObservableCollection
                    <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem> _result =
                        ((
                         System.Collections.ObjectModel.ObservableCollection
                             <SilverlightInEnterprise.Caching.ServiceContract.DTO.SalesOrderItem>)
                         (base.EndInvoke("GetSalesOrderItems", _args, result)));
                return _result;
            }
        }
    }
}